import React, { useState, useEffect, useRef } from 'react';
import styles from './index.less';

import { createStore, combineReducers } from 'redux';
import { Provider } from './react-redux';

import Child from './Child';

var initState = {
  name: '空着呢',
  select: {
    data: '我是数据哦',
  },
};

function reducer1(state = initState, action) {
  if (action.type == 'reducer1/setState')
    return { ...state, ...action.payload };
  return state;
}
function reducer2(state = initState, action) {
  if (action.type == 'reducer2/setState')
    return { ...state, ...action.payload };
  return state;
}

// reducers函数的整合
var reducers = { reducer1, reducer2 };

let store = createStore(combineReducers(reducers));

export default props => {
  return (
    <div className={styles.page}>
      <Provider store={store}>
        <Child />
      </Provider>
    </div>
  );
};
